package com.qianbei.common.net.view;

import android.view.Gravity;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.qianbei.common.R;
import com.qianbei.common.base.BaseApplication;

public class MsgAlert {

    private Toast msgToast;
    private TextView msgText;

    public MsgAlert() {
        View msgView = View.inflate(BaseApplication.mApplication, R.layout.common_msgalert, null);
//				.inflate(R.layout.hb_msgalert, null);
        msgText = (TextView) msgView.findViewById(R.id.message);

        msgToast = new Toast(BaseApplication.mApplication);
        msgToast.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 170);
        msgToast.setDuration(Toast.LENGTH_SHORT);
        msgToast.setView(msgView);
    }

    public void show(String msgStr) {
        if (msgStr != null && !"".equals(msgStr)) {
            msgText.setText(msgStr);
            msgToast.show();
        }
    }

    public void show(String msgStr,int duration) {
        if (msgStr != null && !"".equals(msgStr)) {
            msgToast.setDuration(duration);
            msgText.setText(msgStr);
            msgToast.show();
        }
    }

    public void show(int msgId) {
        if (msgId != -1) {
            msgText.setText(msgId);
            msgToast.show();
        }
    }
}
